package com.xqboss.apps.listener;

import com.xqboss.apps.enums.mq.AppMqDelayEnum;
import com.xqboss.common.core.mq.MqEnum;
import com.xqboss.common.core.mq.MqListener;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.apis.consumer.ConsumeResult;
import org.apache.rocketmq.client.apis.message.MessageView;
import org.springframework.context.annotation.Configuration;

import java.nio.charset.StandardCharsets;
import java.util.Date;

@Slf4j
@Configuration
public class MqDelayTest extends MqListener {
    @Override
    public MqEnum getEnum() {
        return AppMqDelayEnum.DELAY_TEST;
    }

    @Override
    public ConsumeResult solve(MessageView message) {
        log.info(new Date() + " Receive message, Topic is:" + message.getTopic() + ", MsgId is:" + message.getMessageId());
        log.info("消息内容：" +  StandardCharsets.UTF_8.decode(message.getBody()));
        return ConsumeResult.SUCCESS;
    }
}
